package com.gwm.common.advice;


import com.gwm.common.exceptions.ExceptionResult;
import com.gwm.common.exceptions.LyException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class BasicExceptionAdvice {

    @ExceptionHandler(LyException.class)
    public ResponseEntity<ExceptionResult> handleException(LyException ex){
        ex.printStackTrace();   //TODO 在开发阶段为了能更好的解决bug所以现在把bug的信息打印出来
        return ResponseEntity.status(ex.getStatus()).body(new ExceptionResult(ex));
    }


}
